// 注册登录页面
Vue.component("login", {
  template: "#loginTmp",
  data() {
    return {
      username: "",
      password: "",
      isSucceed: false,
    }
  },
  methods: {
    login() {      
      let username_loc = window.localStorage.getItem("username");
      let password_loc = window.localStorage.getItem("password");
      if ((this.username === username_loc) && (this.password === password_loc)) {
        console.log("LOGIN SUCCEED!");
        this.isSucceed = true;
      } else {
        console.log(this.username,this.password);
        
        this.isSucceed = false;
        // window.alert("LOGIN ERROR!");
      }
      this.$emit("emitloginresult", {isSucceed: this.isSucceed})
    }
  }
})


// 注册提示框
Vue.component("tip", {
  template: "#tipTmp",
})

var vm = new Vue({
  el: "#app",
  data: {
    isTip: false,
    isSucceed: false,
  },
  methods: {
    handleLoginResult(value) {
      this.isSucceed = value.isSucceed;
      this.isTip = true;
      setTimeout(() => {
        this.isTip = false;
      },2000)
    }
  },
  beforeCreate() {
    window.localStorage.setItem("username", "admin");
    window.localStorage.setItem("password", "123123");
  }
});